<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML
><HEAD
><TITLE
>EXECUTE</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
REV="MADE"
HREF="mailto:pgsql-docs@postgresql.org"><LINK
REL="HOME"
TITLE="PostgreSQL 9.1.2 Documentation"
HREF="index.html"><LINK
REL="UP"
TITLE="SQL Commands"
HREF="sql-commands.html"><LINK
REL="PREVIOUS"
TITLE="END"
HREF="sql-end.html"><LINK
REL="NEXT"
TITLE="EXPLAIN"
HREF="sql-explain.html"><LINK
REL="STYLESHEET"
TYPE="text/css"
HREF="stylesheet.css"><META
HTTP-EQUIV="Content-Type"
CONTENT="text/html; charset=ISO-8859-1"><META
NAME="creation"
CONTENT="2011-12-01T22:07:59"></HEAD
><BODY
CLASS="REFENTRY"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="5"
ALIGN="center"
VALIGN="bottom"
><A
HREF="index.html"
>PostgreSQL 9.1.2 Documentation</A
></TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="top"
><A
TITLE="END"
HREF="sql-end.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="top"
><A
HREF="sql-commands.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="60%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="20%"
ALIGN="right"
VALIGN="top"
><A
TITLE="EXPLAIN"
HREF="sql-explain.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><H1
><A
NAME="SQL-EXECUTE"
></A
>EXECUTE</H1
><DIV
CLASS="REFNAMEDIV"
><A
NAME="AEN72006"
></A
><H2
>Name</H2
>EXECUTE&nbsp;--&nbsp;execute a prepared statement</DIV
><DIV
CLASS="REFSYNOPSISDIV"
><A
NAME="AEN72014"
></A
><H2
>Synopsis</H2
><PRE
CLASS="SYNOPSIS"
>EXECUTE <TT
CLASS="REPLACEABLE"
><I
>name</I
></TT
> [ ( <TT
CLASS="REPLACEABLE"
><I
>parameter</I
></TT
> [, ...] ) ]</PRE
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN72018"
></A
><H2
>Description</H2
><P
>   <TT
CLASS="COMMAND"
>EXECUTE</TT
> is used to execute a previously prepared
   statement. Since prepared statements only exist for the duration of a
   session, the prepared statement must have been created by a
   <TT
CLASS="COMMAND"
>PREPARE</TT
> statement executed earlier in the
   current session.
  </P
><P
>   If the <TT
CLASS="COMMAND"
>PREPARE</TT
> statement that created the statement
   specified some parameters, a compatible set of parameters must be
   passed to the <TT
CLASS="COMMAND"
>EXECUTE</TT
> statement, or else an
   error is raised. Note that (unlike functions) prepared statements are
   not overloaded based on the type or number of their parameters; the
   name of a prepared statement must be unique within a database session.
  </P
><P
>   For more information on the creation and usage of prepared statements,
   see <A
HREF="sql-prepare.html"
>PREPARE</A
>.
  </P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN72028"
></A
><H2
>Parameters</H2
><P
></P
><DIV
CLASS="VARIABLELIST"
><DL
><DT
><TT
CLASS="REPLACEABLE"
><I
>name</I
></TT
></DT
><DD
><P
>      The name of the prepared statement to execute.
     </P
></DD
><DT
><TT
CLASS="REPLACEABLE"
><I
>parameter</I
></TT
></DT
><DD
><P
>      The actual value of a parameter to the prepared statement.  This
      must be an expression yielding a value that is compatible with
      the data type of this parameter, as was determined when the
      prepared statement was created.
     </P
></DD
></DL
></DIV
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN72041"
></A
><H2
>Outputs</H2
><P
>   The command tag returned by <TT
CLASS="COMMAND"
>EXECUTE</TT
>
   is that of the prepared statement, and not <TT
CLASS="LITERAL"
>EXECUTE</TT
>.
  </P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN72046"
></A
><H2
>Examples</H2
><P
>    Examples are given in the <A
HREF="sql-prepare.html#SQL-PREPARE-EXAMPLES"
><I
>Examples</I
></A
> section of the <A
HREF="sql-prepare.html"
>PREPARE</A
> documentation.
   </P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN72051"
></A
><H2
>Compatibility</H2
><P
>   The SQL standard includes an <TT
CLASS="COMMAND"
>EXECUTE</TT
> statement,
   but it is only for use in embedded SQL.  This version of the
   <TT
CLASS="COMMAND"
>EXECUTE</TT
> statement also uses a somewhat different
   syntax.
  </P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN72056"
></A
><H2
>See Also</H2
><A
HREF="sql-deallocate.html"
>DEALLOCATE</A
>, <A
HREF="sql-prepare.html"
>PREPARE</A
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="sql-end.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="sql-explain.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>END</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="sql-commands.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>EXPLAIN</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>